package cn.kgc.springmvc00.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @author shkstart
 * @create 2019-12-20 15:45
 */
@Controller
@RequestMapping("/user")
public class UserController {
    @RequestMapping(value = "/login.do",method = RequestMethod.GET)
    public String login(){
        int n=10/0;
        return "login";
    }
    @RequestMapping(value = "/login.do",method = RequestMethod.POST)
    public String login(String name, String password, HttpSession session, Model model) {
    if (name.equals("admin")&&password.equals("123456")){
        session.setAttribute("name",name);
        return "redirect:succss.do";
    }else {
        model.addAttribute("msg","用户名或密码错误");
        return "login";
    }
    }
    @RequestMapping("succss.do")
    public  String succss(){
        return "succss";
    }
}
